let router = require('koa-router')()
const path = require("path");
const fileMod = require('../util/File')


/**
 * @swagger
 * /api/weather/cityinfo:
 *    get:
 *      tags:
 *      - 获取天气信息
 *      summary: 获取城市信息
 *      produces:
 *      - application/json
 *      parameters:
 *        - name: pageNum
 *          description: 分页下标
 *          required: false
 *          type: number
 *        - name: pageSize
 *          description: 分页数量
 *          required: false
 *          type: string
 *        - name: name
 *          description: 城市名
 *          required: false
 *          type: string
 *      responses:
 *        200:
 *          description: 返回车辆列表
 *          schema:
 *            type: object
 *            properties:
 *              data:
 *                type: array
 *                default: [
 *                    {
 *       "id": 1764,
 *       "name": "河东区",
 *       "fatherId": 1349,
 *                       "level": 3,
 *                       "code": 120102
 *                   }
 *                ]
 *        401:
 *          description: 参数错误
 * */


//导入app的路由路径
importRoutingPathsByFileName('../service/weather/path/app');
//导入admin的路由路径
importRoutingPathsByFileName('../service/weather/path/super');


/**
 * @swagger
 * /api/weather/cityWeather:
 *    get:
 *      tags:
 *      - 获取天气信息
 *      summary: 获取天气信息
 *      produces:
 *      - application/json
 *      parameters:
 *        - name: id
 *          description: 城市id
 *          required: false
 *          type: number
 *      responses:
 *        200:
 *          description: 返回天气信息和城市信息
 *          schema:
 *            type: object
 *            properties:
 *              data:
 *                type: object
 *                default: {
 *
 *                    "city": {
 *       "id": 1530,
 *       "code": 4301,
 *       "name": "长沙市",
 *       "level": 2,
 *       "fatherId": 1331
 *     },
 *
 *                }
 *        401:
 *          description: 参数错误
 * */


//导入一个文件夹中所有的的路径
function importRoutingPathsByFileName(filesPath) {
    const completeFilesPath = path.join(__dirname, filesPath);
    const arr = fileMod.directoryRouter(completeFilesPath);
    for (const name of arr) {
        const serve = require(path.join(completeFilesPath, (name + '.js')));
        router = new serve().build(router);
    }
}


module.exports = router;

